# a script that reads data from the OECD Trade in Employment database, 2019 edition
# version: Oct 2019
# ENSURE that the script is in the path: addpath ("/[insert the path to your Octave folder]/Octave")

# data on employment that are compatible with the OECD ICIO tables 2018 edition are downloaable from the TiM Principal Indicators database within the OECD.Stat facility at https://stats.oecd.org/Index.aspx?DataSetCode=TIM_2019_MAIN
# however, the format and presentation of these data differ from those of the ICIO CSV files
# therefore, the downloaded data file was manually processed: employment data were allocated to the ICIO country-industries (less split China and Mexico) and stored in columns that correspond to years 2005-2015
# the results are in the file "EMPN(processed).csv", please put it in the folder with the input data files
filename = "/[insert the path to the input data file]/EMPN(processed).csv";
# employment data are only for 51 out of 64 countries (+RoW) in the OECD ICIO tables, the missing data replaced by zeros
# for most countries, employment data are in thousands of persons employed; please see the OECD Science, Technology and Industry Working Paper "Measuring employment in global value chains" for the units of measurement at https://www.oecd-ilibrary.org/deliver/00f7d7db-en.pdf?itemId=%2Fcontent%2Fpaper%2F00f7d7db-en&mimeType=pdf

# when reading data, cut the split rows for China and Mexico; then dimesnsion of each column vector is [65 x 36] x 1 = 2340 x 1
# 1. read the vector of employment e in 2005
e_2005 = dlmread (filename, ",", [1, 1, 2340, 1]);
# 2. read the vector of employment e in 2006
e_2006 = dlmread (filename, ",", [1, 2, 2340, 2]);
# 3. read the vector of employment e in 2007
e_2007 = dlmread (filename, ",", [1, 3, 2340, 3]);
# 4. read the vector of employment e in 2008
e_2008 = dlmread (filename, ",", [1, 4, 2340, 4]);
# 5. read the vector of employment e in 2009
e_2009 = dlmread (filename, ",", [1, 5, 2340, 5]);
# 6. read the vector of employment e in 2010
e_2010 = dlmread (filename, ",", [1, 6, 2340, 6]);
# 7. read the vector of employment e in 2011
e_2011 = dlmread (filename, ",", [1, 7, 2340, 7]);
# 8. read the vector of employment e in 2012
e_2012 = dlmread (filename, ",", [1, 8, 2340, 8]);
# 9. read the vector of employment e in 2013
e_2013 = dlmread (filename, ",", [1, 9, 2340, 9]);
# 10. read the vector of employment e in 2014
e_2014 = dlmread (filename, ",", [1, 10, 2340, 10]);
# 11. read the vector of employment e in 2015
e_2015 = dlmread (filename, ",", [1, 11, 2340, 11]);
# NOTE: in vectors e_*, data for China and Mexico are included in the "main" country categories, and the split country categories are cut off
# save file
clear filename
save "/[insert the path to the output data file]/EMPN_octave";
# clear all
clear
# END of script
